/*
 * 题目描述：给出图，道路之间有两个权重，不同优先级，距离为首，cost为辅
 */
#include <iostream>
#include <cstdio>
#include <climits>
#define INFINITY INT_MAX
using namespace std;
struct Road{
    int dist;
    int cost;

    Road(){
        this->dist = INFINITY;
        this->cost = INFINITY;
    }
};
Road **graph;
int cityNum, pathNum, startCity, endCity, minDist, minCost;
int *minPath;
int *path;
int *vst;

void dfs(int city, int dist, int cost){
    if (city == endCity) {
        if (dist < minDist) {
            minDist = dist;
            minCost = cost;
            for (int i = 0; i < cityNum; i++) {
                minPath[i] = path[i];
            }
        } else if (dist == minDist) {
            if (cost < minCost) {
                for (int i = 0; i < cityNum; i++) {
                    minPath[i] = path[i];
                }
                minCost = cost;
            }
        }
        return;
    }
    if (dist > minDist) {
        return;
    }
    for (int i = 0; i < cityNum; i++) {
        if (vst[i] == 0 && graph[city][i].dist != INFINITY) {
            vst[i] = 1;
            path[city] = i;
            dfs(i, dist + graph[city][i].dist, cost + graph[city][i].cost);
            vst[i] = 0;
        }
    }
}

int main() {
    scanf("%d %d %d %d", &cityNum, &pathNum, &startCity, &endCity);
    graph = new Road *[cityNum];
    for (int i = 0; i < cityNum; i++) {
        graph[i] = new Road[cityNum]();
    }
    path = new int[cityNum]();
    vst = new int[cityNum]();
    minPath = new int[cityNum]();
    minDist = minCost = INFINITY;
    Road r;
    int x, y, dist, cost;
    while (pathNum--) {
        scanf("%d %d %d %d", &x, &y, &dist, &cost);
        graph[x][y].dist = graph[y][x].dist = dist;
        graph[x][y].cost = graph[y][x].cost = cost;
    }
    vst[startCity] = 1;
    dfs(startCity, 0, 0);
    int cur = startCity;
    printf("%d ", startCity);
    while (minPath[cur] != endCity) {
        cur = minPath[cur];
        printf("%d ", cur);
    }
    printf("%d %d %d\n", endCity, minDist, minCost);
    return 0;
}